using System; using System.Collections.Generic; using Shared.SimpleControl; namespace Shared { [System.Serializable] public class RemoteInfo { static RemoteInfo () { Current = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile ("RemoteInfoMsgList"))); if (Current == null) Current = new RemoteInfo (); } /// /// 从服务器读取相应数目的数据 /// public void ReadMsgList (bool needTip) { if (MainPage.LoginUser == null) return; #if HDL new System.Threading.Thread (() => { try { //Application.RunOnMainThread (() => { // MainPage.Loading.Start (Language.StringByID(SimpleControl.R.MyInternationalizationString.load)); //}); var se = new service.hdlcontrol.com_push.WebServicePush (); //var msgList = se.MsgList (rsgID); var msgList = se.GetMessageList (MainPage.LoginUser.MasterID, MainPage.LoginUser.LoginTokenString); if (msgList == null||msgList.Length==0) return; if (msgList.Length == Current.RemoteInfoList.Count && msgList [msgList.Length - 1].MsgTime == Current.RemoteInfoList [Current.RemoteInfoList.Count - 1].MsgTime) return; Current.RemoteInfoList.Clear (); foreach (var msg in msgList) { Current.RemoteInfoList.Add (new RemoteInfoMsg () { Msg = msg.Msg, MsgID = msg.MsgID, MsgTime = msg.MsgTime, MsgType = msg.MsgType }); } Current.Save (); if (msgList.Length > 0) { Application.RunOnMainThread (() => { string tipMsg = Language.StringByID (SimpleControl.R.MyInternationalizationString.NewMessageReceived); if (needTip) { Alert alert = new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), tipMsg, Language.StringByID (SimpleControl.R.MyInternationalizationString.Close), Language.StringByID (SimpleControl.R.MyInternationalizationString.Read)); alert.Show (); alert.ResultEventHandler += (sender, e) => { if (e) { if (Shared.Application.IsPad) { //SimpleControl.Pad.WarningList.ShowWarningListPage (); } else { SimpleControl.Phone.UserMiddle.ShowSettingView (); var msgView = new SimpleControl.Phone.WarningList (); SimpleControl.Phone.UserMiddle.SettingPageView.AddChidren (msgView); msgView.ShowWarningListPage (); SimpleControl.Phone.UserMiddle.SettingPageView.PageIndex = 1; } } }; } else { if (Shared.Application.IsPad) { //SimpleControl.Pad.WarningList.ShowWarningListPage (); } else { SimpleControl.Phone.UserMiddle.ShowSettingView (); var msgView = new SimpleControl.Phone.WarningList (); SimpleControl.Phone.UserMiddle.SettingPageView.AddChidren (msgView); msgView.ShowWarningListPage (); SimpleControl.Phone.UserMiddle.SettingPageView.PageIndex = 1; } } }); } } catch (Exception ex) { Console.WriteLine (ex.Message); if (MainPage.LoginUser.AccountString == "750183166@qq.com") { Application.RunOnMainThread (() => { var ss = new Alert ("", ex.Message, "Close"); ss.Show (); }); } } finally { //Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); //}); } }) { IsBackground = true}.Start(); #endif } public static RemoteInfo Current { get; private set; } public List RemoteInfoList = new List (); public void Del (RemoteInfoMsg msg) { RemoteInfoList.Remove (msg); Save (); } public void CleanAll () { Current.RemoteInfoList.Clear (); Save (); } public void Save () { var saveBytes = CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (Current)); IO.FileUtils.WriteFileByBytes ("RemoteInfoMsgList", saveBytes); } } [System.Serializable] public class RemoteInfoMsg { public long MsgID; public string Msg; public string MsgType; public DateTime MsgTime; } }